import request, { Method } from '~/utils/axios'

interface Params {
  pageNumber: number
  pageSize: number
  memberId: string
  storeId: string
}

// 获取店铺详情
export function getStoreDetail(id: string) {
  return request({
    url: `/buyer/store/store/get/detail/${id}`,
    method: Method.GET,
  })
}

// 查看用户订单列表
export function getOrderList(params: Params) {
  return request({
    url: '/buyer/order/order',
    method: Method.GET,
    params,
  })
}

export function getGoodsInfo(goodsId: string, skuId: string) {
  return request({
    url: `/buyer/goods/goods/sku/${goodsId}/${skuId}`,
    method: Method.GET,
  })
}

// 获取用户浏览足迹
export function getViewHistory(client: 'store' | 'buyer', data: Params) {
  return request({
    url: `/${client}/member/footprint`,
    method: Method.GET,
    params: data,
  })
}

// 获取聊天列表服务接口
export function getTalkList(client: 'store' | 'talk') {
  return request({
    url: client === 'store' ? `/im/talk/${client}/list` : `/im/talk/list`,
    method: Method.GET,
  })
}

export function getTalkDetail(params: { talkId: string, pageNumber: number }) {
  return request({
    url: `/im/message`,
    method: Method.GET,
    params,
  })
}

// 获取店铺相关设置信息
export function getStoreInfo() {
  return request({
    url: '/store/member/user',
    method: Method.GET,
  })
}

// 获取用户相关设置信息
export function getUserInfo() {
  return request({
    url: '/buyer/passport/member',
    method: Method.GET,
  })
}

// 获取用户聊天列表
export function getTalkByUserId(id: string) {
  return request({
    url: `/im/talk/user/${id}`,
  })
}
